# 测试类
import unittest

from survey import AnonymousSurvey

def colect_language():
    question = 'What language did you first learn to speak?'
    my_survey = AnonymousSurvey(question)

    my_survey.show_question()
    print("Enter 'q' at any time to quit.\n")

    while True:
        response = input('Language: ')
        if response == 'q':
            break
        my_survey.store_response(response)

    print("\n Thank you to everyone who participated in the survey!")
    my_survey.show_results()

class TestAnonymousSurvey(unittest.TestCase):

    def setUp(self) -> None:
        question = 'What language did you first learn to speak?'
        self.my_survey = AnonymousSurvey(question)
        self.responses = ['English', 'Spanish', 'Mandarin']

    def test_store_single_response(self):
        self.my_survey.store_response(self.responses[0])

        self.assertIn(self.responses[0], self.my_survey.responses)

    def test_store_three_response(self):
        for response in self.responses:
            self.my_survey.store_response(response)
        for responses in self.responses:
            self.assertIn(response, self.my_survey.responses)

unittest.main()

